import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'
Vue.use(VueRouter)
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';
Vue.use(Antd);
import NProgress from 'nprogress'
import 'nprogress/nprogress.css' 
const router= new VueRouter({
    routes
  })

  router.beforeEach((to, from, next) => {
    if(to.path!=='/login'){
      if(!sessionStorage.getItem('login-user')){
        return next('/login')
      }
    }
    document.title = to.meta.title
    NProgress.start();
    next()
  
  });
  
  router.afterEach(() => {
    NProgress.done();
  });
  

  export default router